<#assign p = p!0>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <#include "/common/common_head.ftl">

    <script>
        function doCheck(menuId){
            $("#m_"+menuId).attr("checked",'true');
        }
    </script>
  </head>

  <body style="padding-top:0px;'>

 		<!-- 主内容区域 S -->
 		<div class="" id="mainBoard">
		<!-- 导航路径 S -->
		<ol class="breadcrumb">
		  <li><a href="#">菜单管理</a></li>
		  <li class="active">添加菜单</li>
		  <li><a href="userList.do">返回</a></li>
		</ol>
		<!-- 导航路径 E -->

		<!-- 标题区 S -->
		<h2 class="sub-header">添加菜单项</h2>
		<!-- 标题区 E -->

		<!-- 内容区 S -->
        <#if user??>
		<form action="saveUser.do" method="post">
		    <div class="input-group">
              <span class="input-group-addon" id="basic-addon1">用户编号</span>
              <input type="text" class="form-control" placeholder="ID" aria-describedby="basic-addon1" name="id" value="${user.id?if_exists}">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon2">登陆名称</span>
              <input type="text" class="form-control" placeholder="name" aria-describedby="basic-addon2" name="name" value="${user.name?if_exists}">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon4">用户密码</span>
              <input type="text" class="form-control" placeholder="permission" aria-describedby="basic-addon4" name="pass" value="">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">用户状态</span>
              <input type="text" class="form-control" placeholder="status" aria-describedby="basic-addon3" name="status" value="${user.status?if_exists}">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">创建时间</span>
              <input type="text" class="form-control" placeholder="createTime" aria-describedby="basic-addon3" name="createTime" value="${user.createTime?if_exists}">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">更新时间</span>
              <input type="text" class="form-control" placeholder="updateTime" aria-describedby="basic-addon3" name="updateTime" value="${user.updateTime?if_exists}">
            </div>


            <div class="input-group">
              <span class="input-group-addon" id="basic-addon5">用户类型</span>
              <select class="form-control" name="type">
                <#if __USER__.type == -1>
                <option value="-1">系统管理员</option>
                </#if>
                <option value="0">普通管理员</option>
              </select>
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon5">群组编号</span>
              <select class="form-control" name="groupId">
                <option value="-1">系统管理员</option>
              </select>
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon6">描述信息</span>
              <input type="text" class="form-control" placeholder="desc" aria-describedby="basic-addon6" name="description" value="${user.description?if_exists}">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon6">权限信息</span>
                <div style="border: 1px solid #ccc;;border-radius: 4px;">
                <!-- menus -->
                <#if menus ??>
                <#assign idx = 0>
                <#list menus as menu>
                    &nbsp;&nbsp;<input type="checkbox" aria-label="..." value="${menu.id}" id="m_${menu.id}" name="menu[${idx}].id">${menu.name}<br/>
                    <#list menu.children as sub>
                    <#assign idx = idx + 1>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|---><input type="checkbox" aria-label="..." value="${sub.id}" id="m_${sub.id}" name="menu[${idx}].id">${sub.name}
                        <#list sub.children as f>
                        <#assign idx = idx + 1>
                            <input type="checkbox" aria-label="..." value="${f.id}" id="m_${f.id}" name="menu[${idx}].id"><span class="label label-default">${f.name}</span>
                        </#list>
                        <br/>


                    </#list>
                    <#assign idx = idx + 1>
                </#list>
                </#if>
                </div>
            </div>

		</form>

		<!-- init permission menus -->
        <script>
            <#list user.menu as m>
                doCheck(${m.id});
            </#list>
        </script>

        <#else>
		<form action="saveUser.do" method="post">
		    <div class="input-group">
              <span class="input-group-addon" id="basic-addon1">用户编号</span>
              <input type="text" class="form-control" placeholder="ID" aria-describedby="basic-addon1" name="id">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon2">登陆名称</span>
              <input type="text" class="form-control" placeholder="name" aria-describedby="basic-addon2" name="name">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon4">用户密码</span>
              <input type="text" class="form-control" placeholder="password" aria-describedby="basic-addon4" name="pass">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">用户状态</span>
              <select class="form-control" name="status">
                 <option value="1">启用</option>
                 <option value="0">禁用</option>
              </select>
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">创建时间</span>
              <input type="text" class="form-control" placeholder="createTime" aria-describedby="basic-addon3" name="createTime">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">更新时间</span>
              <input type="text" class="form-control" placeholder="updateTime" aria-describedby="basic-addon3" name="updateTime">
            </div>


            <div class="input-group">
              <span class="input-group-addon" id="basic-addon5">用户类型</span>
              <select class="form-control" name="type">
                <#if __USER__.type == -1>
                <option value="-1">系统管理员</option>
                </#if>
                <option value="0">普通管理员</option>
              </select>
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon5">群组编号</span>
              <select class="form-control" name="groupId">
                <option value="-1">系统管理员</option>
              </select>
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon6">描述信息</span>
              <input type="text" class="form-control" placeholder="desc" aria-describedby="basic-addon6" name="description">
            </div>

            <div class="input-group">
              <span class="input-group-addon" id="basic-addon6">权限信息</span>
                <div style="border: 1px solid #ccc;;border-radius: 4px;">
                <!-- menus -->
                <#if menus ??>
                <#assign idx = 0>
                <#list menus as menu>
                    &nbsp;&nbsp;<input type="checkbox" aria-label="..." value="${menu.id}" name="menu[${idx}].id">${menu.name}<br/>
                    <#list menu.children as sub>
                    <#assign idx = idx + 1>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|---><input type="checkbox" aria-label="..." value="${sub.id}" name="menu[${idx}].id">${sub.name}
                        <#list sub.children as f>
                        <#assign idx = idx + 1>
                            <input type="checkbox" aria-label="..." value="${f.id}" name="menu[${idx}].id"><span class="label label-default">${f.name}</span>
                        </#list>
                        <br/>
                    </#list>
                    <#assign idx = idx + 1>
                </#list>
                </#if>
                </div>
            </div>
		</form>
        </#if>
		<!-- 内容区 E -->
 		<!-- 主内容区域 E -->

  </body>
</html>
